/**
 * This file is part of ossecdb-extjs.
 *
 * Copyright (C) 2011 Brendan Johnston
 *
 * Contact: brendan@johnston.net.au
 *
 * Project: http://code.google.com/p/ossecdb-extjs/
 *
 * License: http://www.gnu.org/licenses/gpl-3.0.html
 */

Ext.define('OssecWeb.lib.Inet', {
    singleton: true,

	getAton: function (s) {

		var octets = s.split('.');
		
		return (
			octets[0] * Math.pow(256, 3) + 
			octets[1] * Math.pow(256, 2) + 
			octets[2] * Math.pow(256, 1) + 
			octets[3] * Math.pow(256, 0)
		);
	},

	getNtoa: function (ip, delim) {

		if (delim == null) {
			delim = '.';
		}

		return (ip >>> 24) + delim + ((ip >>> 16) & 255) + delim + ((ip >>> 8) & 255) + delim + (ip & 255);
	}

});